/**
 * @requires extend/Control/Overview.js
 */
/**
 * 鹰眼控件，显示主地图窗口在全图范围内的相对位置.
 * @class OpenLayers.Control.ImageOverview
 * @extend <OpenLayers.Control.OverviewMap>
 * @requires extend/Control/Overview.js
 */
OpenLayers.Control.ImageOverview = OpenLayers.Class(OpenLayers.Control.Overview, {
    /**
     * 图片地址
     * @property url
     * @type {String}
     */
    url: null,
    /**
     * 四至
     * @property extent
     * @type {String}
     */
    extent: null,
    /**
     * 固定比例尺
     * @property fixedScaleView
     * @type {Boolean}
     */
    fixedScaleView: true,
    
    /**
     * 绘制
     * @method draw
     */
    draw: function() {
        var bounds;
    	if(!this.extent){
	        var height = (this.map.maxExtent.top-this.map.maxExtent.bottom)/2;
	        var centerx = this.map.maxExtent.left + (this.map.maxExtent.right-this.map.maxExtent.left) /2;
	        var bl = centerx - height*2;
	        var br = centerx + height*2;
	        bounds = new OpenLayers.Bounds(bl,this.map.maxExtent.bottom,br,this.map.maxExtent.top);
    	}else{
    		bounds = this.extent;
    	}
		var imglayer = new OpenLayers.Layer.Image("overview",{
            url: this.url,
            zoomLevels: 1,
            extent: bounds,
            size: this.size
        });
        
		this.layers = [imglayer];
        return OpenLayers.Control.Overview.prototype.draw.apply(this, arguments);
    },
    
    CLASS_NAME: 'OpenLayers.Control.ImageOverview'
});